﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SevenDragon
{
    public class MapConvert
    {
        /// <summary>
        /// 根据坐标获取ID
        /// </summary>
        /// <param name="strX">横坐标</param>
        /// <param name="strY">纵坐标</param>
        /// <returns>地图ID</returns>
        public string getID(XY xy)
        {
            return (xy.X + 501).ToString() + (xy.Y + 501).ToString("D4");
        }

        /// <summary>
        /// 根据地图ID获取坐标
        /// </summary>
        /// <param name="strID">地图ID</param>
        /// <returns></returns>
        public XY getXY(string strID)
        {
            int x = Convert.ToInt32(strID.Substring(0, strID.Length-4))-501;
            int y = Convert.ToInt32(strID.Substring(strID.Length-4,4))-501;
            return new XY(x, y);
        }
    }
}
